import axios from "axios";

 //eslint-disable-next-line
export default {
  //获取用户
  get:({curPage,eachPage})=>axios.get('/api/shopping', {
    params: {
        curPage,eachPage
    }
  })
  .then( ({data})=>data)
  
  .catch(function (error) {
    console.log(error);
  }),
  
  //新增商品
  add:(data)=>axios.post('/api/shopping/add', {
    data
  })
  .then( ({data})=>data)
  
  .catch(function (error) {
    console.log(error);
  }),

  //删除
  del:(_id)=>axios.post('/api/shopping/remove', {
    _id
  })
  .then( ({data})=>data)
  
  .catch(function (error) {
    console.log(error);
  }),

  //通过购物车id查找数据
  find:(_id)=>axios.get(`/api/shopping/findOne/${_id}`)
  .then( ({data})=>data)
  .catch(function (error) {
    console.log(error);
  }),
  //修改
  change:(newData)=>axios.put('/api/shopping/change', {
    newData
  })
  .then( ({data})=>data)
  
  .catch(function (error) {
    console.log(error);
  }),
  //通过用户id查找对应的购物车信息
  findshop:(_id)=>axios.get(`/api/shopping/findshop/${_id}`)
  .then( ({data})=>data)
  .catch(function (error) {
    console.log(error);
  })
}